﻿Imports System.Drawing.Printing

Public Class DossierMedical_Screen

    Private _ctrl As DossierMedical_CTRL

    Public Sub New(ByVal controleur As DossierMedical_CTRL)

        ' Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
        _ctrl = controleur

    End Sub


    Private Sub DossierMedical_Screen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        BarBoutonDOSSIERMEDICAL.BtnImprimer.Visible = True

        RtbDossier.AppendText("Dossier medical de : " & _ctrl.nomAnimal & vbCrLf)
        RtbDossier.AppendText("Propriétaire : " & _ctrl.client & vbCrLf)
        RtbDossier.AppendText(vbCrLf)

        If _ctrl.consultation IsNot Nothing Then
            For Each consul As Consultations In _ctrl.consultation
                RtbDossier.AppendText(consul.DateConsultation & " " & consul.monVeto.NomVeto & vbCrLf)
                For Each ligne In consul.mesLignes
                    RtbDossier.AppendText("   <Acte " & ligne.monIndex & ">")
                    RtbDossier.AppendText(ligne.libelleActe)
                    RtbDossier.AppendText(vbCrLf)
                Next
                If Not String.IsNullOrEmpty(consul.Commentaire) Then
                    RtbDossier.AppendText("Commentaire sur la consultation :" & vbCrLf)
                    RtbDossier.AppendText(consul.Commentaire & vbCrLf)

                End If
                RtbDossier.AppendText(vbCrLf)
            Next
        End If


    End Sub

    Private Sub DossierMedical_Screen_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed

        _ctrl.Dispose()

    End Sub

    Private Sub BarBoutonDOSSIERMEDICAL_Action(ByVal sender As Object, ByVal e As ActionEventArgs) Handles BarBoutonDOSSIERMEDICAL.Action

        If e.Action = actionEnum.Imprimer Then

            Dim configprintr As New PrinterSettings
            Dim printdialog As New PrintDialog
            printdialog.AllowSelection = False
            printdialog.AllowSomePages = False
            printdialog.AllowPrintToFile = False
            printdialog.PrinterSettings = configprintr
            printdialog.ShowDialog()

        End If

    End Sub
End Class